/**
 * 图灵机模拟器常量定义
 * @module constants
 */

// 默认配置
export const DEFAULT_TAPE_LENGTH = 100;
export const DEFAULT_BYTE_SIZE = 1;
export const DEFAULT_HEAD_POSITION = Math.floor(DEFAULT_TAPE_LENGTH / 2);
export const DEFAULT_STATE = 'q0';
export const DEFAULT_SYMBOL = '00';

// 存储键名
export const STORAGE_KEYS = {
    TAPE: 'turingMachine_tape',
    HEAD_POSITION: 'turingMachine_headPosition',
    BYTE_SIZE: 'turingMachine_byteSize',
    STATE: 'turingMachine_state',
    CACHE: 'turingMachine_cache',
    INSTRUCTIONS: 'turingMachine_instructions',
    HISTORY: 'turingMachine_history'
};

// 方向常量
export const DIRECTION = {
    LEFT: 'L',
    RIGHT: 'R',
    STAY: 'S'
};

// 默认指令集
export const DEFAULT_INSTRUCTIONS = [
    // 状态转移示例
    ['q0', '00', 'FF', 'R', 'q1'],
    ['q1', '00', '00', 'L', 'q2'],
    ['q2', 'FF', '00', 'S', 'halt']
];

// 汇编指令映射
export const ASSEMBLY_OPCODES = {
    SET: 'SET',
    MOV: 'MOV',
    LOAD: 'LOAD',
    STORE: 'STORE',
    ADD: 'ADD',
    SUB: 'SUB',
    MUL: 'MUL',
    DIV: 'DIV',
    CMP: 'CMP',
    JMP: 'JMP',
    JZ: 'JZ',
    JNZ: 'JNZ',
    HALT: 'HALT'
};

// 错误消息
export const ERROR_MESSAGES = {
    INVALID_DIRECTION: '无效的移动方向，必须是 L(左)、R(右) 或 S(停)',
    INVALID_POSITION: '无效的位置，超出纸带范围',
    INVALID_BYTE_SIZE: '无效的字节大小，必须是1-8之间的整数',
    INVALID_HEX_VALUE: '无效的十六进制值，必须是2位十六进制字符',
    INVALID_INSTRUCTION: '无效的指令格式，必须是五元组',
    INVALID_ASSEMBLY: '无效的汇编指令',
    TAPE_OVERFLOW: '纸带溢出，无法扩展'
};